package com.myweb.dao.sys.impl;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.myweb.dao.common.CBaseDaoImpl;
import com.myweb.dao.sys.ISysMenuDao;
import com.myweb.entity.sys.SysMenu;
import com.myweb.entity.sys.SysUser;

/**
 * 
 * @TODO  系统菜单DAO实现类
 * @author roye
 * @date May 3, 2013 10:14:04 AM
 * @version V1.0
 */
@Repository
public class CSysMenuDaoImpl  extends CBaseDaoImpl<SysMenu,Integer> implements ISysMenuDao{

	/**
	 * 获取用户权限
	 */
	@SuppressWarnings("unchecked")
	public List<SysMenu> getPrivilegeMenuByUser(SysUser user)
			throws DataAccessException {
		StringBuffer sql = new StringBuffer();
		sql.append(" SELECT sm.* FROM sys_menu sm  ");
		sql.append(" LEFT JOIN sys_role_menu srm ON sm.menuId = srm.menuId ");
		sql.append(" LEFT JOIN sys_user_role sur ON srm.roleId = sur.roleId ");
		sql.append(" WHERE sm.menuSts= 1 and  sur.userId ="+user.getUserId());
		return this.getObjectListByCondition(sql);
	}
}
